package cn.com.qiancheng.service;

import cn.com.qiancheng.dao.StudentDao;
import cn.com.qiancheng.dao.TrinerClassDao;
import cn.com.qiancheng.dao.AddStuDao;
import cn.com.qiancheng.dto.Student;
import cn.com.qiancheng.dto.TrinerClass;

public class AddStuService {
	public int validate(String userName,String realName,String password,String stuClass){
		int i = 0;
		StudentDao dao = new StudentDao();
		Student student = dao.searchStudentByUserName(userName);
		if(student!=null){
			return i;
		}
		TrinerClassDao tcd = new TrinerClassDao();
		TrinerClass tclass = tcd.sreachTrinerClass(stuClass);
		if(tclass==null){
			return i;
		}
		AddStuDao stuDao = new AddStuDao();
		i = stuDao.addStudent(userName, realName, password, tclass.getId());
		return i;
	}
}
